import React from "react"
import {
  withState,
  withHandlers,
  compose,
  lifecycle
} from "recompose"
import {postParam, postJSON, get, putParam} from "server"
import {env, DEV} from "project-config"


const shopDetailCompose = compose(
  withState('data', 'setData', []),
  withHandlers({
    getDetail: ({setData, match}) => {
      return () => {
        get(`/shop/details/${match.params.id}`).then(data => {
          setData(data)
        })
      }
    },
    goBack: ({history}) => {
      return () => {
        history.push(`/app/shop/shops`)
      }
    }
  }),

  lifecycle({
    componentDidMount() {
      const {getDetail} = this.props
      getDetail()
    }
  })
)
export default shopDetailCompose